<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
    <title>Document</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

  </head>
  <body>
    <div id="app">
      <el-button @click="getFun">GET</el-button>
      <el-button @click="postFun">POST</el-button>
      <el-button @click="deleteFun">DELETE</el-button>
      <el-button @click="jsonpFun">JSONP</el-button>
      
    </div>

    <!-- import Vue before Element -->
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
  <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
  <!-- import JavaScript -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          visible: false 
        }
      },
      methods: {
        getFun() {
          console.log('get请求发送了');
          $.ajax({
            type: 'GET',
            url: 'http://127.0.0.1/api/get',
            data: {
              name: '张三',
              age: 20
            },
            success: function (res) {
              console.log(res);
            }
          })
        },
        postFun() {
          console.log('post请求发送了');
          $.ajax({
            type: 'POST',
            url: 'http://127.0.0.1/api/post',
            data: {
              bookName: '围城',
              author: '钱钟书'
            },
            success: function (res) {
              console.log(res);
            }
          })
        },
        deleteFun() {
          console.log('delete请求发送了');
          $.ajax({
            type: 'DELETE',
            url: 'http://127.0.0.1/api/delete',
            success: function (res) {
              console.log(res);
            }
          })
        },
        jsonpFun() {
          console.log('jsonpFun请求发送了');
          $.ajax({
            methods: 'GET',
            url: 'http://127.0.0.1/api/jsonp',
            dataType: 'jsonp',
            success: function (res) {
              console.log(res);
            }
          })
        }
      }
    })
  </script>
  </body>
</html>